package com.yueqian.xiangqi;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class ChineseChese extends JFrame {
    public ChineseChese() {
        this.setTitle("中国象棋");
        this.setSize(630, 630);
        this.setLocationRelativeTo(null);
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

        this.setVisible(true);
    }

    public void paint(Graphics g) {
        Font f = new Font("黑体", Font.BOLD, 30);
        g.setFont(f);
        int length = 60;
        g.drawRect(70, 60, 480, 540);
        for (int i = 0; i < 9; i++) {
            g.drawLine(70, length, 550, length);
            length += 60;
        }
        g.drawString("楚河", 130, 340);
        g.drawString("汉界", 400, 340);
        length = 130;
        for (int i = 0; i < 7; i++) {
            g.drawLine(length, 60, length, 300);
            g.drawLine(length, 360, length, 600);
            length += 60;
        }
        g.drawLine(250, 60, 370, 180);
        g.drawLine(370, 60, 250, 180);
        g.drawLine(250, 480, 370, 600);
        g.drawLine(250, 600, 370, 480);

    }

    public static void main(String[] args) {
        ChineseChese chineseChese = new ChineseChese();
    }
}